package com.tool.xmltool.util;

import cn.hutool.core.text.CharSequenceUtil;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author zhoubin
 * @date 2022/10/13 10:51
 */
public class StrUtil {

    public static boolean regexCheck(String relTxt, String regex) {

        if (CharSequenceUtil.isBlank(regex)) {
            return true;
        }

        Pattern compile = Pattern.compile(regex);
        Matcher matcher = compile.matcher(relTxt);

        return matcher.matches();
    }

    /**
     * 判断字符串是否有换行
     * @param str
     * @return
     */
    public static boolean strHasBr(String  str){
        if(str.contains("\n") || str.contains("\r\n")){
            return true;
        }
        return false;
    }
}
